package cn.stylefeng.guns.modular.customer.wrapper;

import cn.stylefeng.guns.modular.course.entity.Category;
import cn.stylefeng.guns.modular.course.entity.Course;
import cn.stylefeng.guns.modular.course.entity.CourseVideo;
import cn.stylefeng.guns.modular.course.service.CategoryService;
import cn.stylefeng.guns.modular.course.service.CourseService;
import cn.stylefeng.guns.modular.course.service.CourseVideoService;
import cn.stylefeng.guns.modular.customer.entity.Customer;
import cn.stylefeng.guns.modular.customer.service.CustomerService;
import cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper;
import cn.stylefeng.roses.core.util.SpringContextHolder;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Map;

public class CustomerWarpper extends BaseControllerWrapper {

    public CustomerWarpper(Page<Map<String, Object>> page) {
        super(page);
    }

    private CustomerService customerService= SpringContextHolder.getBean(CustomerService.class);
    private CourseService courseService= SpringContextHolder.getBean(CourseService.class);
    private CourseVideoService courseVideoService= SpringContextHolder.getBean(CourseVideoService.class);


    @Override
    protected void wrapTheMap(Map<String, Object> map) {
        Integer customerId=(Integer)map.get("customerId");
        Integer courseId=(Integer)map.get("courseId");
        Integer videoId=(Integer)map.get("videoId");
        Customer customer=customerService.getById(customerId);
        Course course=courseService.getById(courseId);
        CourseVideo courseVideo=courseVideoService.getById(videoId);
        map.put("nickname",customer.getNickname());
        map.put("mobile",customer.getMobile());
        map.put("courseName",course.getName());
        map.put("courseVideoName",courseVideo.getName());
    }
}
